package util.gui;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;

public class Panel extends Component
{
	protected int minWidth=2*LookAndFeel.borderSize;
	protected int minHeight=2*LookAndFeel.borderSize;
	protected Component child;
	
	/**
	 * Adds a component to the panel.
	 * @param child - component to add.
	 */
	public void add(Component child)
	{
		this.child=child;
		this.setWidth(2*LookAndFeel.borderSize+child.getWidth());
		this.setHeight(2*LookAndFeel.borderSize+child.getHeight());
		child.setMaxHeight(this.getHeight()-2*LookAndFeel.borderSize);
		child.setMaxWidth(this.getWidth()-2*LookAndFeel.borderSize);
	}
	
	public void render(GameContainer gc,Graphics g,int x,int y)
	{
		super.render(gc,g,x,y);
		if(child!=null)
			child.update(gc,g,x+LookAndFeel.borderSize,y+LookAndFeel.borderSize);
	}
}
